package org.coder.consumer_nacos_9002.controller;

import jakarta.annotation.Resource;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/consumer")
public class consumer {
    @Resource
    private RestTemplate restTemplate;

    @Resource
    private DiscoveryClient discoveryClient;

    String URL = "http://provider-service-nacos/wegGis/hello";

    @GetMapping("/test")
    public String test(){
        return restTemplate.getForObject(URL,String.class);
    }

    @GetMapping("/dis")
    public void showDiscoveryInfo(){
       System.out.println(discoveryClient.getInstances("provider-service-nacos"));
       System.out.println(discoveryClient.getServices());
    }
}
